import React   from 'react';
// 非受控组件
class App extends React.Component {

  myuserpassword = React.createRef();
  myusername = React.createRef();

  render() {
    return (
      <div>
        <h1>登录页</h1>
        <div>
          <span> 用户名</span>
          <input type="text" ref={this.myusername} defaultValue="cly" />
        </div>

        <div>
          <span> 密码</span>
          <input type="text" ref={this.myuserpassword} value="123456" />
        </div>
       

        <button
          onClick={() => {
            console.log(this.myusername.current.value);
            console.log(this.myuserpassword.current.value);
          }}
        >
          登录
        </button>
        <button
          onClick={() => {
            this.myusername.current.value = "";
            this.myuserpassword.current.value = "";
          }}
        >
          重置
        </button>
        {/* <Child myvalue={this.myusername.current.value}/> */}
      </div>
    );
  }
}
export default App;